package com.example.shoppingmall.cotroller;

import com.example.shoppingmall.Utils.Page;
import com.example.shoppingmall.config.MyLog;
import com.example.shoppingmall.pojo.Return;
import com.example.shoppingmall.service.ReturnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/return")
public class ReturnController {
    @Autowired
    ReturnService returnService;

    //退货单条件查询+分页+点击排序
    @MyLog(value = "订单管理->退货单->条件查询")
    @RequestMapping("/returnlist")
    public String returnlist(@RequestParam(value = "reno",required = false) String reno,@RequestParam(value = "returnno",required = false) String returnno, @RequestParam(value = "rorderno",required = false) String rorderno,
                             @RequestParam(value = "rphone",required = false) String rphone, @RequestParam(value = "logisticsno",required = false) String logisticsno,
                             @RequestParam(value = "status",required = false) String status, @RequestParam(value = "pageno",defaultValue = "1") String pageno,
                             @RequestParam(value = "pageSize",defaultValue = "6") String pageSize, Model model){
        if(status==null){
            status="0";
        }
        int count=returnService.returncount(returnno,rorderno,rphone,logisticsno,status);
        int num=(Integer.valueOf(pageno)-1)*(Integer.valueOf(pageSize));
        Page page=new Page();
        page.setPageno(Integer.valueOf(pageno));
        page.setPageCount(count);
        List<Return> returnList=returnService.getreturns(reno,returnno,rorderno,rphone,logisticsno,status,num,Integer.valueOf(pageSize));
        model.addAttribute("page",page);
        model.addAttribute("returnList",returnList);
        //查询回显
        model.addAttribute("returnno",returnno);
        model.addAttribute("rorderno",rorderno);
        model.addAttribute("rphone",rphone);
        model.addAttribute("logisticsno",logisticsno);
        return "order/Returnorder";
    }
}